﻿using System;

namespace Dwork
{
    class Program
    {
        /// <summary>
        /// 输出数组的最大最小值，将数组进行冒泡函数
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            int[] numbers = { 97, 65, 32, 17, 58, 43, 79, 81, 23, 10 };
            int maxNum = numbers[0];
            int minNum = numbers[0];
            for (int i = 0; i <numbers.Length; i++)
            {
                numbers[i] = Convert.ToInt32(numbers[i]);
            }
            int temp = 0;
            for (int i = numbers.Length-1; i > 0; i--)
            {
                for (int j = 0; j < i; j++)
                {
                    if (numbers[j] > numbers[j + 1])
                    {
                        temp = numbers[j + 1];
                        numbers[j + 1] = numbers[j];
                        numbers[j] = temp;
                    }
                    else
                    {

                    }
                }
            }
            for (int i = 0; i < numbers.Length; i++) 
            {
                if (maxNum < numbers[i]) 
                {
                    maxNum = numbers[i];
                }
                if (minNum > numbers[i]) 
                {
                    minNum = numbers[i];
                }
            }
            Console.WriteLine(" ");
            Console.WriteLine("冒泡排序结果从小到大排序如下；");
            for (int b = 0; b < numbers.Length; b++)
            {
                Console.Write(numbers[b] + " ");
            }
            Console.WriteLine(" ");
            Console.WriteLine($"最大值：{maxNum},最小值：{minNum}");
            Console.ReadKey();
        }
    }
}
